<template>
     <!--登录表单的容器-->
    <div class="login_container" :style="note">
     <!-- 登录区域-->
        <div class="login_box">
         <!--头像-->
          <div class="avatar_box">
              <img src="../assets/img/log.jpg">
          </div>
          <!--表单-->
          <el-form :model="loginForm" :rules="loginRules" ref="loginForm" label-width="0px" class="login_form">
            <el-form-item prop="username">
              <el-input v-model="loginForm.username" prefix-icon="el-icon-user-solid"></el-input>
            </el-form-item>
            <el-form-item prop="password">
              <el-input v-model="loginForm.password" prefix-icon="el-icon-lock"></el-input>
            </el-form-item>
            <el-form-item  prop="verifyCode" >
              <div class="verify_code">
              <el-input v-model="loginForm.verifyCode" prefix-icon="el-icon-mobile" class="verify"></el-input>
              <img src="../assets/img/msFXK1.gif" >
              </div>
            </el-form-item>
            <el-form-item class="login_btn">
              <el-button type="primary" @click="submitForm('loginForm')">立即登录</el-button>
              <el-button @click="resetForm('loginForm')">重置</el-button>
            </el-form-item>
          </el-form>
        </div>
    </div>
</template>

<script>
export default {
  name: 'Login',
  data() {
    return {
      loginForm: {
        username: '',
        password:'',
        verifyCode:'',
      },
      note: {
        height:"590px",
        backgroundImage: "url(" + require("../assets/img/bg1.jpg") + ")",
        backgroundRepeat: "no-repeat",
        backgroundSize: "100% 100%",
        marginTop: "1px",
      },
      loginRules: {
        username: [
          { required: true, message: '请输入用户名称', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
        ],
        password: [
          { required: true, message: '请输入登录密码', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
        ],
        verifyCode: [
          { required: true, message: '请输入验证码', trigger: 'blur' }
        ],
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
         this.$router.push("/main")
        } else {
          console.log('error submit!!');
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
}
</script>

<style scoped>
  .login_container{
    height: 620px;
    background-color: aquamarine;
  }
  .login_box{
    width: 450px;
    height: 380px;
    background-color: #FFFFFF;
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);

    background-color: transparent;  /*背景透明*/
    border:1px solid #135e23;
    box-shadow: 0 0 25px #003dff;
  }
  .avatar_box{
    width: 130px;
    height: 130px;
    border: 1px solid #eeeeee;
    border-radius: 50%;
    padding: 10px;
    box-shadow: 0 2px 100px 0 rgba(0,0,0,0.1);
    margin: -55px auto;
    background-color: #FFFFFF;
  }
  img{
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #EEEEEE;
  }
  .login_form{
    position: absolute;
    left: 14px;
    top: 120px;
    width: 95%;
    padding: 0px 20px ;
    box-sizing: border-box;
  }
  .login_btn{
      display: flex;
      justify-content: flex-end;
  }
  .verify_code{
    display: flex;
  }
  .verify{
    width: 70%;
    justify-content: left;
  }
  .verify_code img{
    background-size: contain;
    width: 30%;
    height: 60%;
    justify-content: flex-end;
  }
</style>
